package main

import "fmt"

//结构体
type Student struct{
	name string
	age int
}

func (stu *Student) hello (person string) string{
	return fmt.Sprintf("hello %s, I am %s", person, stu.name)
}

//嵌套结构体
type person struct{
	Name string
	Age int
	Contact struct{
		Phone, City string
		Code int
	}
}

func main() {
	fmt.Println("vim-go")
	//实例化方法1
	stu := &Student{
		name: "StudentWang",
		age: 18,
	}
	fmt.Println(stu.name, stu.age)
	fmt.Println(stu.hello("TeacherCali"))
	
	//实例化方法2 
	stu2 := new(Student)
	fmt.Println(stu2.name, stu2.age)
	stu2.name = "wanglianfang"
	fmt.Println(stu2.name, stu2.age)


	//实例化
	p1 := person{
		Name: "Feng",
		Age:15,
	}
	p1.Contact.Phone="182xxxxxxxx"
	p1.Contact.City="湖南长沙"
	p1.Contact.Code=202

	fmt.Println(p1)

	//实例化
	//p2 := new(person)
}
